<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link th:href="@{/erp/Widget/icheck/icheck.css}" rel="stylesheet" type="text/css"/>
    <!--[if IE 7]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome-ie7.min.css}"/>
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <![endif]-->
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
<!--    <script type="text/javascript" th:src="@{/erp/js/H-ui.js}"></script>
    <script type="text/javascript" th:src="@{/erp/js/H-ui.admin.js}"></script>-->
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
    <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
    <style>
        .imgg img {
            max-width: 100px
        }
    </style>
    <title>商品审核</title>
</head>
<body>
<div class=" page-content clearfix">
    <div id="products_style">
        <div class="search_style">
            <form>
                <ul class="search_content clearfix">
                    <li><label class="l_f">商品名称</label><input name="productName" type="text" class="text_add" placeholder="输入商品名称"
                                                              style=" width:250px"/></li>

                    <li style="width:90px;">
                        <button type="button" class="btn_search" id="btn_search"><i class="icon-search"></i>查询</button>
                    </li>
                </ul>
            </form>
        </div>
        <div class="border clearfix">
       <span color="red" class="l_f">
	    已审核
           <input id="yetAudit" style="border:none;width: 36px;text-align:center"/>件商品，待审核
           <input id="noAudit" style="border:none;width: 36px;text-align:center"/>件商品，未通过
           <input id="notAudit" style="border:none;width: 36px;text-align:center"/>件商品
       </span>

        </div>
        <table class="table table-striped table-bordered table-hover" id="sample-table">
            <thead>
            <tr>

                <th width="250px">商品编号</th>
                <th width="250px">商品名称</th>
                <th width="280px">商品图片</th>
                <th width="200px">商品种类</th>
                <th width="180px">零售价（￥）</th>
                <th width="200px">类别（企业）</th>
                <th width="180px">添加时间</th>
                <th width="200px">商品状态</th>
                <th width="200px">审核状态</th>
                <th width="250px">操作</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--商品详情图层-->
<div class="select_menber" id="select_menber_style" style="display:none">

    <ul class=" page-content">
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>商品名称：<input id="pName" style="border:none;"/></label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>商品图片： <a href="#" class="product_Display imgg"><img id="pImg" title="图片"/></a>&nbsp;</label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>商品编号：<input id="pNumber" style="border:none;"/></label>

        </div>

        <div class="Operate_cont clearfix">
            <label><span class="c-red"></span>商品分类：&nbsp;<input id="pEnterprise" style="border:none;"/></label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>产地：<input id="pLocal" style="border:none;"/></label>
        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>材质：<input id="pMaterial" style="border:none;"/></label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>品牌：<input id="pBrand" style="border:none;"/></label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>零售价格：<input id="pPrice" style="border:none;"/></label>

        </div>
        <div class="Operate_cont clearfix">
            <label ><span class="c-red"></span>商品质量：<input id="pQuality" style="border:none;"/></label>

        </div>

        <div class="Operate_cont clearfix">
            <label >备注:<input id="pRemarks" style="border:none;"/></label>

        </div>
        <div class="">
            <div class="" style=" text-align:center">
            </div>
        </div>
    </ul>
</div>

</div>
</div>
</div>
</div>
</div>
</body>
</html>

<script>
    /*产品-已上架的可以进行审核*/
    function member_start(obj,id){
        layer.confirm('确认要通过审核吗？',function(index){
            member_start();
            //商品审核
            var pNumber = $(obj).parent().parent().children("td:eq(0)").text();
            $.ajax({
                type: 'post',
                dataType: 'json',
                async: false,//同步或异步
                url: '/product_check/yaudit',
                data: {
                    'pNumber': pNumber
                },
                success: function (da) {
                    if (!da.rs){
                        layer.msg(da.msg, {icon: 2, time: 2000});
                    }
                }
            })
            $(obj).parents("tr").find(".td-audit").html('<span class="label label-success radius">审核通过</span>');
            /*$(obj).remove();*/
            layer.msg('审核通过!',{icon: 6,time:1000});
            window.parent.document.getElementById('iframe').contentWindow.location.reload(true);
        });
    }

    /*产品-不通过审核*/
    function member_strop(obj,id){
        layer.confirm('确认要通过审核吗？',function(index){
            member_start();
            //商品审核
            var pNumber = $(obj).parent().parent().children("td:eq(0)").text();
            $.ajax({
                type: 'post',
                dataType: 'json',
                async: false,//同步或异步
                url: '/product_check/naudit', 
                data: {
                    'pNumber': pNumber
                },
                success: function (da) {
                    if (!da.rs){
                        layer.msg(da.msg, {icon: 2, time: 2000});
                    }
                }
            })
            $(obj).parents("tr").find(".td-audit").html('<span class="label label-danger radius">不通过审核</span>');
            /*$(obj).remove();*/
            layer.msg('不通过审核!',{icon: 6,time:1000});
            window.parent.document.getElementById('iframe').contentWindow.location.reload(true);
        });
    }
    //商品列表
    $(function () {
        var table = $('#sample-table').dataTable({
            searching : false,  //取消本地搜索
            serverSide: true,   //开始服务器分页
            aoColumnDefs: [
                {"orderable": false, "aTargets": [1, 2, 3, 4, 5, 6]}// 制定列不参与排序
            ],
            ajax: {
                url : '/product_check/page',
                type : 'post',
                data : function (d) {
                    var data = $('form').serialize();   //获取查询条件

                    //获取分页信息
                    var searchParams= {
                        start : d.start,
                        length : d.length,
                    };
                    data = data + '&' + $.param(searchParams);
                    return data;
                }
            },
            columns : [
                { "data": "pnumber" },
                { "data": "pname" },
                { "data": "pimg" ,"createdCell":function (td, cellData, rowData, row, col){
                        $(td).addClass("order_product_name");
                        $(td).empty().append('<a onclick="member_select(this)" href="javascript:;" class="product_Display imgg"><img src="/images/'+cellData+'" title="'+rowData.pname+'"/>')
                    }},
                { "data": "pmaterial" },
                { "data": "pprice" },
                { "data": "pbrand" },
                { "data": "paddtime" },
                { "data" : "pstatus","createdCell":function (td, cellData, rowData, row, col) {
                        if(cellData=="1"){
                            $(td).addClass("td-status")
                            $(td).empty().append('<span class="label label-success radius">已上架</span>')
                        }else if (cellData=="-1"){
                            $(td).addClass("td-status")
                            $(td).empty().append('<span class="label label-defaunt radius">已下架</span>')
                        }
                    }},
                { "data": "astatus", "createdCell": function (td, cellData, rowData, row, col) {
                        if (cellData=="1") {
                            $(td).addClass("td-audit")
                            $(td).empty().append('<span class="label label-success radius">审核通过</span>');
                        }else if (cellData=="-1") {
                            $(td).addClass("td-audit")
                            $(td).empty().append('<span class="label label-info radius">待审核</span>');
                        }else if (cellData=="0") {
                            $(td).addClass("td-audit")
                            $(td).empty().append('<span class="label label-danger radius">不通过审核</span>');
                        }
                    }},
                {"data" : "pimg", "createdCell": function (td, cellData, rowData, row, col) {
                    if(rowData.pstatus=="1"){
                        if(rowData.astatus=="1"){
                            $(td).empty().append(
                                '<a onClick="member_strop(this)" id="onebut" href="javascript:;" title="审核不通过"  class="btn btn-xs btn-danger"><i>✖</i></a>  \n' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;" class="btn btn-xs btn-success" ><i>≣</i></a> ');
                        }else if(rowData.astatus=="-1"){
                            $(td).empty().append('<a onClick="member_start(this)" id="onebtt" href="javascript:;" title="审核通过"   class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;" class="btn btn-xs btn-success" ><i>≣</i></a> ');
                        }else if(rowData.astatus=="0"){
                            $(td).empty().append('<a onClick="member_start(this)" id="onebtt" href="javascript:;" title="审核通过"   class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;" class="btn btn-xs btn-success" ><i>≣</i></a> ');
                        }
                    }else if(rowData.pstatus=="-1"){
                        if(rowData.astatus=="1"){
                            $(td).empty().append('<a onClick="member_strop(this)" id="onebut" href="javascript:;" title="审核不通过"  class="btn btn-xs btn-danger"><i>✖</i></a>' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;" class="btn btn-xs btn-success" ><i>≣</i></a> ');
                        }else if(rowData.astatus=="-1"){
                            $(td).empty().append('<a onClick="member_start(this)" id="onebtt" href="javascript:;" title="审核通过"   class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>' +
                                '<a onClick="member_strop(this)" id="onebut" href="javascript:;" title="审核不通过"  class="btn btn-xs btn-danger"><i>✖</i></a>' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;"  class="btn btn-xs btn-success"  ><i class="icon-list bigger-120"></i></a> ');
                        }else if(rowData.astatus=="0"){
                            $(td).empty().append('<a onClick="member_start(this)" id="onebtt" href="javascript:;" title="审核通过"   class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>' +
                                '<a title="详情" onclick="member_select(this)" href="javascript:;" class="btn btn-xs btn-success" ><i>≣</i></a> ');
                        }
                     }
                }},
            ]
        })
        //搜索
        $('#btn_search').click(function () {
            table.fnUpdate();
        })
    })
    //商品详情
    function member_select(e){
        var pNumber= $(e).parent().parent().children("td:eq(0)").text();
        $.ajax({
            type:'post',
            dataType:'json',
            async: false,//同步或异步
            url:'/product_check/pNumber',
            data :{
                'pNumber' : pNumber
            },
            success: function(da){
                if (!da.rs){
                    layer.msg(da.msg, {icon: 2, time: 2000});
                    return;
                }
                var d = da.data;
                console.log(d.pimg)
                document.getElementById('pName').value=d.pname;
                $("#pImg").attr("src",d.pimg);
                document.getElementById('pNumber').value=d.pnumber;
                document.getElementById('pEnterprise').value=d.penterprise;
                document.getElementById('pLocal').value=d.plocal;
                document.getElementById('pMaterial').value=d.pmaterial;
                document.getElementById('pBrand').value=d.pbrand;
                document.getElementById('pPrice').value=d.pprice;
                document.getElementById('pQuality').value=d.pquality;
                document.getElementById('pRemarks').value=d.premarks;
            }
        })
        layer.open({
            type: 1,
            title: '查询详情',
            maxmin: true,
            shadeClose:false, //点击遮罩关闭层
            area : ['600px' , ''],
            content:$('#select_menber_style'),
            btn:['确定'],

        });
    }

    //商品详情
    function member_select(e){
        var pNumber= $(e).parent().parent().children("td:eq(0)").text();
        $.ajax({
            type:'post',
            dataType:'json',
            async: false,//同步或异步
            url:'/product_check/pNumber',
            data :{
                'pNumber' : pNumber
            },
            success: function(da){
                if (!da.rs){
                    layer.msg(da.msg, {icon: 2, time: 2000});
                    return;
                }
                var d = da.data;
                console.log(d.pimg)
                document.getElementById('pName').value=d.pname;
                $("#pImg").attr("src",'/images/'+d.pimg);
                document.getElementById('pNumber').value=d.pnumber;
                document.getElementById('pEnterprise').value=d.penterprise;
                document.getElementById('pLocal').value=d.plocal;
                document.getElementById('pMaterial').value=d.pmaterial;
                document.getElementById('pBrand').value=d.pbrand;
                document.getElementById('pPrice').value=d.pprice;
                document.getElementById('pQuality').value=d.pquality;
                document.getElementById('pRemarks').value=d.premarks;
            }
        })
        layer.open({
            type: 1,
            title: '查询详情',
            maxmin: true,
            shadeClose:false, //点击遮罩关闭层
            area : ['600px' , ''],
            content:$('#select_menber_style'),
            btn:['确定'],

        });
    }
    //未审核
    $(function () {
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/product_check/noAudit',
            success: function(da){
                console.log(da);
                if (da.rs){

                    var d = da.data;
                    document.getElementById('noAudit').value=d;
                }else{
                    layer.msg(da.msg, {icon: 2, time: 2000});
                }

            }
        })
    })
    //已审核
    $(function () {
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/product_check/yetAudit',
            success: function(da){
                if (!da.rs){
                    layer.msg(da.msg, {icon: 2, time: 2000});
                    return;
                }
                var d = da.data;
                console.log("--------"+d);
                document.getElementById('yetAudit').value=d;
                console.log(d)
            }
        })
    })
    //未通过审核
    $(function () {
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/product_check/notAudit',
            success: function(da){
                if (!da.rs){
                    layer.msg(da.msg, {icon: 2, time: 2000});
                    return;
                }
                var d = da.data;
                document.getElementById('notAudit').value=d;
            }
        })
    })
</script>
</body>
</html>
